<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <script type="module" src="https://unpkg.com/rapidoc@7.0.4/dist/rapidoc-min.js"></script>
</head>
<body>
  <rapi-doc
    id="rapidoc"
    spec-url="swagger.yaml"
    allow-try="false"
    allow-authentication="false"
    allow-spec-url-load="false"
    allow-spec-file-load="false"
    show-info="false"
    heading-text="Digdag REST API"
    header-color="#f0f2f4"
    regular-font="BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"
  >
    <div slot="logo" style="height:36px;width:36px;margin-left:5px;margin-right:auto;">
      <a href="https://digdag.io"><img src="../_static/logo/dig-dag-logo-tr.png" alt="Digdag logo" height="36" width="36" /></img></a>
    </div>
  </rapi-doc>

  <script>
    // Modify style here because RapiDoc doesn't highlight deprecated endpoints.
    // Deprecated endpoints are highlighted with "read" mode https://github.com/mrin9/RapiDoc/issues/91,
    // but not with default "view" mode.
    const markDeprecated = function() {
      const rapidocRoot = document.querySelector("#rapidoc").shadowRoot  // Shadow DOM is not directly accessible
      rapidocRoot.querySelectorAll(".m-endpoint").forEach(function(endpointEl) {
        // Find endpoints whose description is empty (undocumented) or includes /deprecate/i (deprecated).
        const descText = endpointEl.querySelector(".descr").textContent
        if (!descText || descText.toLowerCase().includes("deprecate")) {
          // Mark it as deprecated by changing style
          endpointEl.querySelector(".method").setAttribute("style", "color:#bbb;border-color:#bbb;")
          endpointEl.querySelector(".path").setAttribute("style", "color:#bbb;")
          endpointEl.querySelector(".descr").setAttribute("style", "color:#bbb;")
        }
      })
    }
    // Use setTimeout instead of spec-loaded event because spec-loaded is not added rapidoc
    // since 7.0.5 and it is not released yet.
    //document.getElementById("doc").addEventListener('spec-loaded', markDeprecated)
    setTimeout(markDeprecated, 500)
  </script>
</body>
</html>
